package com.sch.www.ele.services.impl;


import com.sch.www.codeGenerator.base.BaseServicesSimpleImp;
import com.sch.www.codeGenerator.base.CustomPage;
import com.sch.www.ele.entity.Elevator;
import com.sch.www.ele.entity.ElevatorExample;
import com.sch.www.ele.mapper.ElevatorMapper;
import com.sch.www.ele.services.ElevatorServices;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class ElevatorServicesImpl extends BaseServicesSimpleImp<Elevator, ElevatorExample, ElevatorMapper, ElevatorServices> implements ElevatorServices {


    @Override
    protected ElevatorExample getExampleNewInstance() {
        return new ElevatorExample();
    }

    @Override
    protected String getTableName() {
        return null;
    }


    @Override
    public CustomPage<Elevator> listByExample(String registrationCode, String elevatorNorms, int pageNum, int pageSize) {

        ElevatorExample elevatorExample = new ElevatorExample();
        ElevatorExample.Criteria criteria = elevatorExample.createCriteria();
        if (StringUtils.isNotEmpty(registrationCode)) {
            criteria.andRegistrationCodeLike(likePacking(registrationCode));
        }
        if (StringUtils.isNotEmpty(elevatorNorms)) {
            criteria.andElevatorNormsLike(likePacking(elevatorNorms));
        }
        return getMapper().selectByExampleStartPage(elevatorExample, pageNum, pageSize);
    }
}
